{include file="public/header" /}



<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>空间管理</h3>
                <h5></h5>
            </div>
            {include file="public/admin_items" /}
        </div>
    </div>

    <div class="upload-con" id="uploader" style="display: none;">
        <form method="post" action="" id="fileupload" enctype="multipart/form-data">
            <div class="upload-con-div">{$Think.lang.select_file}：
                <div class="sc-upload-btn"> <a href="javascript:void(0);"><span>
                            <input type="file" hidefocus="true" size="1" class="input-file" name="file" multiple="multiple"/>
                        </span>
                        <p><i class="fa fa-upload"></i>{$Think.lang.album_class_list_img_upload}</p>
                    </a> </div>
            </div>
            <div sctype="file_msg"></div>
            <div class="upload-pmgressbar" sctype="file_loading"></div>
            <div class="upload-txt"><span>{$Think.lang.album_batch_upload_description}{$Think.config.image_max_filesize}KB{$Think.lang.album_batch_upload_description_1}</span> </div>
        </form>
    </div>
    <form method="get" name="formSearch">
        <div class="sc-search-form">
            <dl>
                <dt>{$Think.lang.g_album_keyword}</dt>
                <dd><input class="txt" name="keyword" id="keyword" value="{$Request.get.keyword}" type="text"></dd>
            </dl>
            <div class="btn_group">
                <a href="javascript:document.formSearch.submit();" class="btn " title="{$Think.lang.sc_query}">{$Think.lang.sc_query}</a>
                <a href="{:url('Goodsalbum/pic_list',['aclass_id'=>$Request.param.aclass_id])}" class="btn btn-default" title="{$Think.lang.sc_cancel}">{$Think.lang.sc_cancel}</a>
            </div>
        </div>
    </form>


    <div class="sc-picture-list">
        <div class="alert alert-info"> <strong>{$Think.lang.album_plist_replace_same_type}</strong> </div>
        <ul>
            {foreach name="albumpic_list" item="v" }
            <li>
                <dl>
                    <dt>
                        <!--<input class="checkitem checkbox" type="checkbox" name="delbox[]" value="{$v.apic_id}" >-->
                        <div class="picture"><a data-lightbox="lightbox-image" data-title="{$v.apic_size},{$Think.lang.upload_to}{$v.apic_uploadtime|date='Y-m-d',###}" href="{:goods_thumb($v,1280)}"> <img id="img_{$v.apic_id}" src="{:goods_thumb($v)}"></a></div>
                        <input id="{$v.apic_id}" class="editInput1" readonly onDblClick="$(this).unbind();_focus($(this));" value="{$v.apic_name}" title="{$Think.lang.album_plist_double_click_edit}" style="cursor:pointer;">
                        <span onDblClick="_focus($(this).prev());" title="{$Think.lang.album_plist_double_click_edit}"><i class="fa fa-pencil"></i></span></dt>
                    <dd class="date">
                        <p>{$Think.lang.album_plist_upload_time}{$Think.lang.sc_colon}{$v.apic_uploadtime|date="Y-m-d",###}</p>
                        <p>{$Think.lang.album_plist_original_size}{$Think.lang.sc_colon}{$v.apic_spec}</p>
                    </dd>
                    <dd class="buttons">
                        <div class="upload-btn"><a href="javascript:void(0);"> <span>
                                    <input type="file" name="file_{$v.apic_id}" id="file_{$v.apic_id}" class="input-file" size="1" hidefocus="true" sctype="replace_image" />
                                </span>
                                <div class="upload-button"><i class="fa fa-upload"></i>{$Think.lang.album_plist_replace_upload}</div>
                                <input id="submit_button" style="display:none" type="button" value="{$Think.lang.slide_image_upload}" onClick="submit_form($(this))" />
                            </a>
                        </div>
                        <a href="javascript:scLayerOpen('{:url('Goodsalbum/album_pic_move',['id'=>$v.apic_id])}','{$Think.lang.album_plist_move_album}')"><i class="fa fa-arrows"></i>{$Think.lang.album_plist_move_album}</a>
                        <a href="javascript:void(0)" onclick='submit_delete({$v.apic_id})'><i class="fa fa-trash-o"></i>{$Think.lang.album_plist_delete_img}</a>
                        <a href="javascript:void(0)" class="submit_cancel"><i class="fa fa-trash-o"></i>取消编辑</a>
                    </dd>
                </dl>
            </li>
            {/foreach}
        </ul>
    </div>
    {$show_page}
</div>
<script>
    jQuery.browser = {};
    (function () {
        jQuery.browser.msie = false;
        jQuery.browser.version = 0;
        if (navigator.userAgent.match(/MSIE ([0-9]+)./)) {
            jQuery.browser.msie = true;
            jQuery.browser.version = RegExp.$1;
        }
    })();
</script>
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/js/fileupload/jquery.iframe-transport.js" charset="utf-8"></script>
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/js/fileupload/jquery.ui.widget.js" charset="utf-8"></script>
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/js/fileupload/jquery.fileupload.js" charset="utf-8"></script>
<script src="{$Think.PLUGINS_SITE_ROOT}/jquery.poshytip.min.js"></script>
<link rel="stylesheet" href="{$Think.PLUGINS_SITE_ROOT}/js/jquery.lightbox/css/lightbox.min.css">
<script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery.lightbox/js/lightbox.min.js"></script>
<script>
    $(function () {
        $('.tip').poshytip({
            className: 'tip-yellowsimple',
            alignTo: 'target',
            alignX: 'center',
            alignY: 'bottom',
            offsetX: 0,
            offsetY: 5,
            allowTipHover: false
        });


        // 替换图片
        $('input[sctype="replace_image"]').each(function () {
            $(this).fileupload({
                dataType: 'json',
                url: ADMINSITEURL + '/Goodsalbum/replace_image_upload.html?id=' + $(this).attr('id'),
                done: function (e, data) {
                    var param = data.result;
                    if (param.state == 'true') {
                        img_refresh(param.id);
                    } else {
                        alert(param.message);
                    }
                }
            });
        });

    });
// 重新加载图片，替换上传使用
    function img_refresh(id) {
        $('#img_' + id).attr('src', $('#img_' + id).attr('src') + "?" + 100 * Math.random());
    }
    //控制图片名称input焦点可编辑
    function _focus(o) {
        var name;
        obj = o;
        name = obj.val();
        obj.removeAttr("readonly");
        obj.attr('class', 'editInput2');
        obj.select();
        obj.blur(function () {
            if (name != obj.val()) {
                _save(this);
            } else {
                obj.attr('class', 'editInput1');
                obj.attr('readonly', 'readonly');
            }
        });
        $('.date').hide();
        $('.buttons').show();



    }
    function _save(obj) {
        $.post("{:url('Goodsalbum/change_pic_name')}", {id: obj.id, name: obj.value}, function (data) {
            if (data == 'false') {
                layer.msg('{$Think.lang.sc_common_op_fail}');
            } else {
                layer.msg('{$Think.lang.sc_common_op_succ}');
            }
        });
        obj.className = "editInput1";
        obj.readOnly = true;
    }
    function submit_delete(ids_str) {
        _uri = ADMINSITEURL + "/Goodsalbum/del_album_pic.html?apic_id=" + ids_str;
        scLayerConfirm(_uri, '{$Think.lang.sc_ensure_del}');
    }

    $('.submit_cancel').click(function () {
        $('.date').show();
        $('.buttons').hide();
    });


</script>